var checkRechargeMoney = function (v) {
    v = v || $('#money').val();

    /*var withmaxmoney = 50000;
    if(v > withmaxmoney) {
        wjtips('充值金额不能大于' + withmaxmoney + ' 元');
        return false;
    }*/

    var withminmoney = 50;
    if (v < 50) {
        wjtips('充值金额不能小于' + withminmoney + ' 元');
        return false;
    }

    return true;
};

var keyupMoney = function (e) {
    e.value = e.value.replace(/\b(0+)/gi, '');
    e.value = e.value.replace(/[^\d]/gi, '');
};

//检验手机验证码
var checkPhonecode = function (v) {
    v = v || $('#scode').val();
    if (v.length != 6) {
        wjtips("请输入6位短信验证码");
        return false;
    } else {
        return true;
    }
};

function chargeConfimSendSMS() {
    var cid = $("#cid").val();
    var money = parseFloat($("#money").val(), 2);
    if (!checkRechargeMoney(money)) return false;
    layer.open({
        type: 2,
        content: '验证码获取中...'
    });

    setTimeout(function () {
        $.ajax({
            type: "post",
            url: "/uc/recharge/quick_pay.html",
            dataType: "json",
            async: false,
            data: {
                cid: cid,
                money: money
            },
            success: function (d) {
                if (d.code == 1) {
                    layer.closeAll();
                    wjtips(d.msg);
                    setTime();
                } else {
                    layer.closeAll();
                    wjtips(d.msg);
                    return false;
                }
            }
        });
    }, 1500);
}


function setTime() {
    var intTime = 59; //秒数
    beginTime = setInterval(function () {
        var o = $("#btnSendMsg");
        if (intTime == 0) {
            clearInterval(beginTime);
            o.removeClass('dis');
            o.text('重新获取');
            intTime = 59;
        } else {
            o.addClass('dis');
            o.text(intTime + "s后重新获取");
            intTime--;
        }
    }, 1000);
}